package com.zbdx.service.impl;

import com.zbdx.dao.IOrderDao;
import com.zbdx.dao.impl.OrderDaoImpl;
import com.zbdx.domain.Order;
import com.zbdx.service.IOrderServcie;

import java.sql.SQLException;
import java.util.List;

/**
 * TODO
 *
 * @author shengyuee
 * @version 1.0
 * 2024/9/10 16:26
 */
public class OrderServiceImpl implements IOrderServcie {
    private IOrderDao orderDao = new OrderDaoImpl();
    @Override
    public boolean register(Order user) {
        return false;
    }

    /**
     * 删除用户信息
     *
     * @param id
     * @return
     * @throws SQLException
     */

    @Override
    public Order findById(int id) throws SQLException {
        Order order = orderDao.selectById(id);
        return order;
    }
    @Override
    public boolean removeOrderById(int id) throws SQLException {
        int res = orderDao.deleteById(id);
        if(res > 0){
            return true;
        }
        return false;
    }
    @Override
    public boolean addOrder(Order order) throws SQLException {
        int res = orderDao.insert(order);
        if(res > 0){
            return true;
        }
        return false;
    }
    @Override
    public List<Order> findAll() throws SQLException {
        List<Order> orders = orderDao.selectAll();
        return orders;
    }
}
